#include "form.h"
#include "ui_form.h"
#include "file.h"
#include <QStringList>

Form::Form(QString filepath,QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::Form)
{
    ui->setupUi(this);
    this->setWindowTitle("表单");
    ui->tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
    QStringList header;
    QStringList data;
    File file;
    file.read(filepath,header,data);
    int count=0;
    int num=0;
    for (const QString &item : data) {
        if(count==8)
        {
            num++;
            count=0;
        }
        if(count==0)
        {
            count++;
            continue;
        }
        ui->tableWidget->setItem(num, count-1, new QTableWidgetItem(item));
        count++;
    }
}

Form::~Form()
{
    delete ui;
}

void Form::setItem(int row, int column, QTableWidgetItem *item)
{
    ui->tableWidget->setItem(row, column, item);
}
